﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>1015game</title>
    <link href="css/jfcj.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="js/jQueryRotate.2.2.js"></script>
<script type="text/javascript" src="js/jquery.easing.min.js"></script>
    <script type="text/javascript">
	$(function(){ 
    $("#startbtn").rotate({ 
        bind:{ 
            click:function(){//绑定click单击事件 
                 var a = Math.floor(Math.random() * 360); //生成随机数 
                 $(this).rotate({ 
                         duration:3000,//转动时间间隔（转动速度） 
                         angle: 0,  //开始角度 
                        animateTo:3600+a, //转动角度，10圈+ 
                        easing: $.easing.easeOutSine, //动画扩展 
                        callback: function(){ //回调函数 
                            alert('中奖了！'); 
                        } 
                 }); 
            } 
        } 
    }); 
});     
</script>
</head>
<body>
    <div class="w">
        <div class="w2">
            <div class="left">
                <div class="jfDetail">
                    <a style="padding-left: 20px;" href="www.bbs.1015game.com" target="_top">
                        亲爱的用户，请登录</a></div>
                <div class="left_date">
                </div>
                <div class="left_list">
                    <!-- 中奖信息开始 -->
                    <div class="zjList">
                        <div class="zjListMiddle">
                            <div id="suP" class="zjListMiddles">
                                <div id="su1" style="float: left;">
                                </div>
                                <div id="su2" style="float: left;">
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- 中奖信息结束 -->
                </div>
                <div class="left_tip">
                <br />
                </div>
            </div>
            <div class="right">
                <!-- 转盘开始 -->
                <div class="cjbox">
                    <div class="cjconbox">
                        <div class="cjzpcon">
                            <div class="cjzparea">
                                <div class="TurntableBox" style="background: url(zp.gif) no-repeat">
                                    <div id="aDiv" class="PointerBox">
                                        <span>&#160;</span></div>
                                    <div id="pointer" class="contentLZhuanBtn">
                                        <span class="pngfix"><img src="start.png" id="startbtn"></span></div>
                                </div>
                                <div class="jifenMsg" id="layer1" style="display: none;">
                                    <div class="closeWindow">
                                        <a href="###" onclick="closeLayer1();goOn()"></a>
                                    </div>
                                    <span class="jftsTxt"><span id="signLet"></span></span><span class="blank0"></span>
                                    <div class="closeBtnDiv">
                                        <a href="###" onclick="closeLayer1();goOn()"></a>
                                    </div>
                                </div>
                                <div class="jifenMsg" id="layer2" style="display: none;">
                                    <div class="closeWindow">
                                        <a href="###" onclick="closeLayer();goOn()"></a>
                                    </div>
                                    <div id="Win">
                                        <div class="JfTitle">
                                            <b>恭喜您</b></div>
                                        <span class="jftsTxt"><b>获得了<span id="listNameBox"></span></b></span>
                                    </div>
                                    <div id="unWin">
                                        <div class="JfTitle" style="padding: 30px 0px;">
                                            <b id="b_info">很遗憾，没中奖</b></div>
                                    </div>
                                    <span class="blank0"></span>
                                    <div class="closeBtnDiv">
                                        <a href="###" onclick="closeLayer();goOn()"></a>
                                    </div>
                                </div>
                                <div class="delJfTip">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- 转盘结束 -->
            </div>
        </div>
    </div>
    <script type="text/javascript">
        $(".jfRulebtn").hover(function () {
            $(this).addClass("active");
        }, function () {
            $(this).removeClass("active");
        });
        var theurl = window.location.href;


        $.ajax({
    //验证用户是否登录
            url: "check.php",
            dataType: 'json',
            timeout: 10000,
            cache: false,
            success: function (data) {
                if (data.status == 0) {
                    $(".jfDetail").html("<a style=' padding-left:20px;'  href='www.bbs.1015game.com' target='_top'>亲爱的用户，请登录</a>");
                }
                else {
                    $(".jfDetail").html("亲爱的会员：<span>" + data.login + "</span>(<span id='Inpointer'>" + data.point + "</span>)");
                }
            }
        });
	//通过ajax的方式加载已经中奖用户的信息
        $.ajax({
            url: "awardInfo.php",
            dataType: 'html',
            timeout: 10000,
            cache: false,
            success: function (json) {
                $("#su1").html(json);
            }
        });

        window.onload = function () {
            setTimeout(function () {
                var pros;
                function $_for(id) { return document.getElementById(id); }
                $_for("su2").innerHTML = $_for("su1").innerHTML;
                var suLen = $_for("su1").getElementsByTagName("li").length;
                var suH = suLen * 24;
                function scrollUps() {
                    var tt = 50
                    if ($_for("suP").scrollTop <= suH) {
                        $_for("suP").scrollTop++;
                    }
                    else {
                        $_for("suP").scrollTop = 0;
                    }
                    pros = setTimeout(function () { scrollUps(); }, tt);
                }
                scrollUps();
            }, 5000)
        }


        //var Prize = {Name:["肌龄端粒酶舒润整肌水（滋润）40ml","静佳Jcare天使爱美丽蜂蜜修护细纹抗皱面膜（28ml×1pc)","静佳Jplus薰衣草精油 3ml","静佳Jplus大马士革玫瑰水润天丝面膜单片装30ml","静佳品牌通用券10元券（满百减十7日内有效）","很遗憾，没中奖","乐蜂全场10元券（满两百减十7日内有效）","JMIXP心情面膜·柔滑紧致果纤面膜（25ml*1）","静佳JCARE地中海绿藻锁水蚕丝隐形面膜 30ml*1","静佳JcareHAKO100微肽玻尿酸胶原蛋白胶囊 450mg×120粒（原装德国进口）","静佳Jplus 玫瑰润颜嫩白花酿面膜（保湿 美白）110g","很遗憾，没中奖"]};

        var ctxs = 15;
        var getVal, getstate, awardname = "", getData = 0;
        var duixiang;
        function begin() {
            $(".contentLZhuanBtn span").html("");
            $.ajax({
                url: "doLottery.php",
                dataType: 'json',
                timeout: 10000,
                error: function () {
                    debugger;
                    //alert("服务器没有返回数据，可能服务器忙，请重试");
                    $("#layer1").css("display", "block");
                    $(".contentLZhuanBtn span").html("<a href='###' class='start' onclick='begin()'></a>");
                    $("#signLet").html("服务器繁忙，请稍后重试");
                },
                cache: false,
                success: function (data) {
                    getVal = $.trim(data.award_index);
                    //  alert(data.result);
                    getstate = data.result;
                    if (getstate == -3) {
                        $("#layer1").css("display", "block");
                        $(".contentLZhuanBtn span").html("<a href='###' class='start' onclick='begin()'></a>");
                        $("#signLet").html("今天您已参加1015大转盘，感谢您的参与");
                    }
                    else if (getstate == -2) {
                        //alert("请登录");
                        $("#layer1").css("display", "block");
                        $(".contentLZhuanBtn span").html("<a href='###' class='start' onclick='begin()'></a>");
                        $("#signLet").html("<a href='www.bbs.1015game.com' target='_top'><img src='logins.jpg' /></a>");
                    }
                    else if (getstate == -1) {
                        $("#layer1").css("display", "block");
                        $("#signLet").html("您的次数已经用完,不能参加活动,谢谢您的关注!");
                        //$(".contentLZhuanBtn span").html("");
                    }
                    else {
                        if (getstate == 1) {
                            awardname = $.trim(data.award_name);
                        }
                        $(".contentLZhuanBtn span").html("<a href='###' class='stop' onclick='end()'></a>");
                        //var Intime = $("#Inpointer").html();
                        var Intime = parent.document.getElementById("Inpointer").innerHTML;
                        if (Intime >= 5) {
                            $("#Inpointer").html(Intime - 5);
                            parent.document.getElementById("Inpointer").innerHTML = Intime - 5;
                        }
                        getData = ctxs + getVal * 30;
                        t = setInterval(function () {
                            doRotate();
                            if (vvcount > 100) {
                                end();                             
                            }
                        }, 30);

                    }
                }
            });
        }
        function closeLayer() {
            $("#layer2").css("display", "none");
            angle = 0;
            rotate();
       	    el.style.top = 332 - (el.offsetHeight / 2) + "px";
            el.style.left = 372 - (el.offsetWidth / 2) + "px";
	}
        function closeLayer1() {
            $("#layer1").css("display", "none");
        }
        function showLayer1() {
            $("#layer1").css("display", "block");
            $("#signLet").html("您的次数已经用完,不能参加活动,谢谢您的关注!");
        }
        function goOn() {
            if (getstate == -1) {
                $(".contentLZhuanBtn span").html("<a href='###' class='start' onclick='showLayer1()'></a>");
            }
            else {
                $(".contentLZhuanBtn span").html("<a href='###' class='start' onclick='begin()'></a>");
            }
        }
        /*
        奇数:(n-1)*(n-1)/2-(n-1)/2;
        偶数:(n-1)*(n/2-1);
        */
        //var getData=ctxs+getVal*30;
        var iNum, data;
        var el = document.getElementById("aDiv");
        var angle = 0, angles = 0;
        var pi = Math.PI;
        function degToRad(x) { return (x / (360 / (2 * pi))); }
        function radToDeg(x) { return (x * (360 / (2 * pi))); }
        function rotate() {
            var rad = degToRad(angle);
            costheta = Math.cos(rad);
            sintheta = Math.sin(rad);
            //var el = document.getElementById(name);
            if (el.filters) {
                el.style.filter = "progid:DXImageTransform.Microsoft.Matrix()";
                el.filters.item("DXImageTransform.Microsoft.Matrix").SizingMethod = "auto expand";
                el.filters.item("DXImageTransform.Microsoft.Matrix").FilterType = "bilinear";
                el.filters.item("DXImageTransform.Microsoft.Matrix").M11 = costheta;
                el.filters.item("DXImageTransform.Microsoft.Matrix").M12 = -sintheta;
                el.filters.item("DXImageTransform.Microsoft.Matrix").M21 = sintheta;
                el.filters.item("DXImageTransform.Microsoft.Matrix").M22 = costheta;
            }
            else if (window.navigator.userAgent.indexOf("Firefox") >= 1) {
                el.style.MozTransform = "rotate(" + angle + "deg)";
            }
            else if (window.navigator.userAgent.indexOf("Chrome") >= 1) {
                el.style.WebkitTransform = "rotate(" + angle + "deg)";
            }
            else if (window.navigator.userAgent.indexOf("Safari") >= 1) {
                el.style.WebkitTransform = "rotate(" + angle + "deg)";
            }
            else if (window.navigator.appName == "Opera") {
                el.style.OTransform = "rotate(" + angle + "deg)";
            }

        }
        var l = 0, iAcc = 1;
        var vvcount = 1;
        function doRotate() {
            iAcc++;
            vvcount++;
            if (iAcc >= 50) {
                iAcc = 50;
            }
            angle += iAcc;
            rotate();
            el.style.top = 332 - (el.offsetHeight / 2) + "px";
            el.style.left = 372 - (el.offsetWidth / 2) + "px";
        }
        var t, z, ts, hh;
        /*function endsp(o){
        end();
        o.disabled = "disabled";
        }*/
        function end() {
            vvcount = 1;
            $(".contentLZhuanBtn span").html("");
            clearInterval(t);
            iNum = iAcc * (iAcc + 1) / 2;
            data = angle - iAcc + iNum;
            ts = data % 360;
            if (ts > getData) {
                hh = 360 - ts + getData;
            }
            else {
                hh = getData - ts;
            }
            angle += hh;
	    z = setInterval(function () {

                iAcc--;
                angle += iAcc;
                rotate();
                el.style.top = 332 - (el.offsetHeight / 2) + "px";
                el.style.left = 372 - (el.offsetWidth / 2) + "px";
                if (iAcc == 0) {

                    clearInterval(z);
                    if (getstate == 1 || getstate == 3 || getstate == 5 || getstate == 8 || getstate == 10) {
                        $("#layer2").css("display", "block").attr("class", "jifenMsg");
                        $("#b_info").html(awardname);
                    }
                    else {
                        $("#layer2").css("display", "block").attr("class", "jifenMsgs");
                        $("#listNameBox").html(awardname);
                    }
                }
            }, 50)
        }      
    </script>
</body>
</html>
